<?php
/*
 * Smarty Template handler for database templates
 *
 */
function string_get_template($tpl_string, &$tpl_source, &$smarty_obj) {
	/*
	 * The first function, source() is supposed to retrieve the resource. 
	 * Its second parameter $source is a variable passed by reference where 
	 * the result should be stored. The function is supposed to return TRUE 
	 * if it was able to successfully retrieve the resource and FALSE otherwise.
	 *
	 */
	$tpl_source = $tpl_string;
    if ($tpl_source) return true;
	else return false;
}
function string_get_timestamp($tpl_id, &$tpl_timestamp, &$smarty_obj) {
	/*
	 * The second function, timestamp() is supposed to retrieve the last modification 
	 * time of the requested resource, as a UNIX timestamp. The second parameter 
	 * $timestamp  is a variable passed by reference where the timestamp should be 
	 * stored. The function is supposed to return TRUE if the timestamp could be 
	 * succesfully determined, or FALSE otherwise.
	 *
	 */

	// always say template has been modified
	$tpl_timestamp = time();
	return true;
}
function string_get_secure($tpl_name, &$smarty_obj) {
	/*
	 * The third function, secure()is supposed to return TRUE or FALSE, depending on 
	 * whether the requested resource is secure or not. This function is used only for 
	 * template resources but should still be defined.
	 *
	 */
    // assume all templates are secure
    return true;
}
function string_get_trusted($tpl_name, &$smarty_obj) {
	/*
	 * The fourth function, trusted() is supposed to return TRUE or FALSE, depending on 
	 * whether the requested resource is trusted or not. This function is used for only 
	 * for PHP script components requested by  {include_php} tag or {insert}  tag with 
	 * the src attribute. However, it should still be defined even for template resources.
	 *
	 */
}


$smarty->register_resource("string", array("string_get_template",
                                       	   "string_get_timestamp",
                                       	   "string_get_secure",
                                       	   "string_get_trusted"));
